﻿<div class="modal fade" id="myModal_AddGords" tabindex="-100" role="dialog" data-backdrop="static" aria-labelledby="myModalAddGoos" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h5 class="modal-title" id="myModalLabel_AddGordsSort"><span class="glyphicon glyphicon-plus text-danger"></span>添加<span class="label label-danger"> @ViewData["GoodsSortName"]</span> 分类下具体商品</h5>
            </div>
            <div class="modal-body">
                <form action="#">
                    <div class="form-group">
                        <label for="addname">商品名称:</label>
                        <input type="text" id="input_AddGords" class="form-control" placeholder="商品名称">

                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <span class="text-danger" style="display:none">输入商品分类不能为空</span>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="btn_AddGords_">提交</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //模态框关闭之后触发
    $("#myModal_AddGords").on('hidden.bs.modal', function (e) {
        $("#Pannel_Goodslist").load('Admin/GoodssByTeamID/' + '@ViewData["GoodsSortID"]');
    });
    //增加大类下面具体商品的ajax
    $("#btn_AddGords_").click(function () {
        if ($("#myModal_AddGords").find("input").val() == "") {
            $("#myModal_AddGords .modal-footer").find("span").show();
        }
            //--------------------------------------------------
        else {
           
            $.ajax({
                type: 'POST',
                data: "name="+$("#myModal_AddGords").find("input").val()+"&GoosSortID="+'@ViewData["GoodsSortID"]',
                url: 'Admin/btn_AddGords',
                success: function (data) {

                    if (data == "ok") {
                      //$("#myModal_AddGords").modal("hide");
                        //刷新下拉菜单绑定的商品分类
                     
                        //增加添加成功信息
                       
                        $("#myModal_AddGords .modal-footer").find("span").show().html("添加成功！");
                    }
                    else { alert("没有成功"); }

                },
                error: function (error) {
                    alert(error.responseText);
                }
            });
        }


    });
</script>